import { request, config } from 'utils';

const { api: { department } } = config;

/**
 * 获取当前工会的所有部门ß
 * @param {*} params 
 */
export async function queryAllDept (params) {
  return request({
    url: department.allDepts,
    method: 'get',
    data: params,
  });
}

/**
 * 创建部门
 * @param {*} params 
 */
export async function createDepartment (params) {
  return request({
    url: department.createDept,
    method: 'post',
    data: params,
  });
}

/**
 * 添加用户到某部门
 * @param {*} param0 
 */
export async function addUserToDept ({ users, dept }) {
  return request({
    url: department.addUserToDept,
    method: 'post',
    data: {
      users,
      dept,
    },
  });
}

/**
 * 查找所有的可选择用户
 * @param {*} params 
 */
export async function queryAllCanSelectedUsers (params) {
  return request({
    url: department.allCanSelectedUsers,
    method: 'get',
    data: params,
  });
}

/**
 * 将用户从某部门移除
 * @param {*} param0 
 */
export async function removeUserFromDept ({ users, dept }) {
  // return request({
  //   url: department.removeUserFromDepartment,
  //   method: 'post',
  //   data: {
  //     users,
  //     dept,
  //   },
  // });
  return request({
    url: department.removeUserFromDept,
    method: 'post',
    data: {
      users,
      dept,
    },
  });
}

export async function getAllUsersWithDepartment (params) {
  return request({
    url: department.getUsersWithDepartment,
    method: 'get',
    data: params,
  });
}
